<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.book.dao.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>尚硅谷会员注册页面</title>

<link type="text/css" rel="stylesheet" href="static/css/css.css">

</head>
<body>
	<div class="header">
		<ul>
			<li><a href="BooksServlet">Home</a></li>
			<li><a href="BorrowServlet">借阅信息</a></li>
			<li><a href="UsersServlet">用户信息</a></li>
		</ul>
		<div class="center-right">
			<form action="BooksServlet" method="post">
				<input class="input" type="text" name="textName"
					placeholder="即刻搜索.."> <input class="input2" type="submit"
					value="搜索">
			</form>
		</div>
	</div>
	<table class="tab">
		<tr>
			<th>id</th>
			<th>编号</th>
			<th>书名</th>
			<th>价格</th>
			<th>出版社</th>
			<th>作者</th>
			<th colspan="3">操作</th>
		</tr>

		<%
			Object obj = request.getAttribute("list");
		//借阅跳转
		Object flag = request.getSession().getAttribute("user_id");

		if (obj == null) {
			request.getRequestDispatcher("../../index.jsp").forward(request, response);
			return;
		}

		List<BookBean> list = (List<BookBean>) obj;

		int pageCurrent = (Integer) (request.getAttribute("pageCurrent"));
		int count = (Integer) (request.getAttribute("count"));
		for (BookBean bookBean : list) {
		%>


		<tr>
			<td><%=bookBean.getBook_id()%></td>
			<td><%=bookBean.getISBN()%></td>
			<td><%=bookBean.getBookName()%></td>
			<td><%=bookBean.getPrice()%></td>
			<td><%=bookBean.getPress()%></td>
			<td><%=bookBean.getAuthor()%></td>
			<td><a
				href="BookUpdateServlet?no=<%=bookBean.getBook_id()%>&pageCurrent2=<%=pageCurrent%>">删除</a></td>
			<td><a
				href="pages/home/homeUpdate.jsp?no=<%=bookBean.getBook_id()%>&pageCurrent2=<%=pageCurrent%>">修改</a></td>
			<%
				String str = "UsersServlet?book_id=" + bookBean.getBook_id();
			if (flag != null) {
				//如果user_id已存
				int user_id = (int)flag;
				str = "pages/home/borrowPage.jsp?book_id=" + bookBean.getBook_id()+"&user_id="+ user_id;
			}
			%>
			<td><a href="<%=str%>">借阅</a></td>
		</tr>
		<%
			}
		%>
	</table>


	<div class="boww">
		<ul>
			<li><a href="BooksServlet">首页</a></li>
			<li>
			<a href="BooksServlet?pageCurrent=<%=pageCurrent == 1 ? 1 : pageCurrent - 1%>">上一页</a>
			</li>
			
			<li>
			<a href="BooksServlet?pageCurrent=<%=pageCurrent == (count + 9) / 10 ? (count + 9) / 10 : pageCurrent + 1%>">下一页</a>
			</li>
			
			<li>
			<a href="BooksServlet?pageCurrent=<%=(count + 9) / 10%>">尾页</a>
			</li>
			
			<li>
			<a href="pages/home/homeUpdate.jsp">添加</a>
			</li>
			</ul>
	</div>




</body>
</html>